package 华为OD机试真题2023.基础题;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class HJ02_木板 {
    public static void main(String[] args) throws FileNotFoundException {
        Scanner in = new Scanner(new File("src/main/java/华为OD机试真题2023/基础题/input/02.txt"));
        int n = in.nextInt();
        int m = in.nextInt();
        Queue<Integer> q = new PriorityQueue<>((x, y) -> x - y); //最小优先队列
        for (int i = 0; i < n; i++) {
            q.add(in.nextInt());
        }
        for (int i = 1; i <= m; i++) {
            Integer num = q.poll();
            num += 1;
            q.add(num);
        }
        System.out.println(q.peek());
    }
}
